package pers.dawnyang.config;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;
import pers.dawnyang.modular.system.service.ConfigService;
import pers.dawnyang.modular.system.service.DictTypeService;

/**
 * 项目启动完成后，执行
 * 
 * @author dawn yang
 * @date 2021/05/08
 */
@Component
@Order(9)
public class ApplicationRunnerImpl implements ApplicationRunner {

  @Autowired
  private DictTypeService dictTypeService;

  @Autowired
  private ConfigService configService;

  @Override
  public void run(ApplicationArguments args) throws Exception {
    // 初始化字典到缓存
    dictTypeService.initDictCache();
    // 初始化系统配置到数据库
    configService.initConfigData();
    // 初始化系统配置到缓存
    configService.initConfigCache();
  }
}
